const BinaryTree = require("../utils/binaryTree")
let arr = [4,2,7,1,3,6,9]
let rootObj = new BinaryTree(arr);
var invertTree = function(root) {
    if(!root)return[]
    const queue = [root]
    while(queue.length){
        const node = queue.shift()
        const temp = node.left
        node.left = node.right
        node.right = temp
       if(node.left) queue.push(node.left)
       if(node.right) queue.push(node.right)
    }
    return root
}
const result = invertTree(rootObj.root)
console.log("🚀 ~ result:", result)
